package LC;

/**
 * @ClassName LC14
 * @Description: TODO
 * @Author hl
 * @Date 2020/9/14
 * @Version V1.0
 **/
public class LC14 {
    public String longestCommonPrefix(String[] strs) {
        if(strs==null||strs.length==0){
            return "";
        }
        int len=strs[0].length();
        for(int i=0;i<len;i++){
            char target=strs[0].charAt(i);
            for(int j=1;j<strs.length;j++){
                if(i==strs[j].length()||strs[j].charAt(i)!=target){
                    return  strs[0].substring(0,i+1);
                }
            }
        }
        return  strs[0];
    }
}
